module.exports = function(ngModule){
    ngModule.run(['$rootScope', '$window', '$location', '$log','$templateCache','$cacheFactory', function ($rootScope, $window, $location, $log,$templateCache,$cacheFactory) {  

          $rootScope.$on('$stateChangeSuccess', stateChangeSuccess);  

          function stateChangeSuccess($rootScope) { 
              $templateCache.removeAll(); 
              $window.scrollTo(0,0);
          } 
          $rootScope.cache = $cacheFactory('myCache');
          $rootScope.cache.removeAll();
    }]).config(['$urlRouterProvider','$locationProvider','$stateProvider','$httpProvider',function($urlRouterProvider,$locationProvider,$stateProvider,$httpProvider) {
          $urlRouterProvider.otherwise('/');
             if (!$httpProvider.defaults.headers.get) {
                $httpProvider.defaults.headers.get = {};
              }
            $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
            $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
            $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
            $locationProvider.hashPrefix('');
            $locationProvider.html5Mode(true);

        // $locationProvider.hashPrefix(''); 
          // $urlRouterProvider
          //   .otherwise('/home');
            $stateProvider
                // home
                // .state('home', {
                //     name:'home',
                //     url: '/home',
                //     template: require('./view/home.html'),
                //     reload:true,
                //     cache:false, 
                //     controller:'homeController',
                //     resolve: {
                //       '': ['$q', '$ocLazyLoad', ($q, $ocLazyLoad) => {
                //         return $q(resolve => {
                //           // https://webpack.js.org/api/module-methods/#require-ensure
                //           require.ensure([], () => {
                //             let homeModule = require('./components/home/homeModule.js')(angular);
                //             $ocLazyLoad.load({
                //               name: 'homeModule'
                //             });
                //             resolve(homeModule);
                //           });
                //         })
                //       }]
                //     },
                // })
              .state("content", {
                url: "/",
                reload:true,
                cache:false,
                views:{
                    "bodyInfo":{template: require('./view/bodyInfo.html'),
                        controller:'bodyInfoCtrl'},
                    "header":{template:require('./view/header.html'),
                        controller:'headerCtrl'
                    },
                    "footer":{template: require('./view/footer.html'),
                        controller:'footerCtrl'
                    }
                }
             }).state("content.strategy", {  //实战攻略
                    url: "strategy",
                    views:{
                        "bodyInfo@":{template: require('./view/strategy/strategy.html'),
                            controller:'strategyCtrl'
                        }
                    }
             }).state("content.teamintr", {  //团队建设
                    url: "teamintr",
                    views:{
                        "bodyInfo@":{template: require('./view/teamintr/teamintr.html'),
                            controller:'teamintrCtrl'
                        }
                    }
             }).state("content.news", {//新闻中心
                    url: "news",
                    reload:true,
                    cache:false,
                    views: {
                        "bodyInfo@":{
                            template: require('./view/news/news.html'),
                            controller:'newsCtrl'
                        }
                    }
                }).state("content.businessGuide", {//业务指南
                    url: "businessGuide",
                    reload:true,
                    cache:false,
                    views: {
                        "bodyInfo@":{
                            template: require('./view/businessGuide/businessGuide.html'),
                            controller:'businessGuideCtrl'
                        }
                    }
                }).state("content.noPer", {//不良资产
                    url: "noPer",
                    reload:true,
                    cache:false,
                    views: {
                        "bodyInfo@":{
                            template: require('./view/noPer/noPer.html'),
                            controller:'noPerCtrl'
                        }
                    }
                }).state("content.Execute", {//执行联盟
                    url: "Execute",
                    reload:true,
                    cache:false,
                    views: {
                        "bodyInfo@":{
                            template: require('./view/Execute/Execute.html'),
                            controller:'ExecuteCtrl'
                        }
                    }
                })
	}]);
	
}
